home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13515 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1023 b 

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Recursion Question
  5. Date: Mon, 08 Apr 96 12:06:06 GMT
  6. Organization: none
  7. Message-ID: <828965166snz@genesis.demon.co.uk>
  8. References: <4k14o1$2k2@isis.fiu.edu> <3166CECC.354E@infi.net>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <3166CECC.354E@infi.net> srndtree@infi.net "Steve Rountree" writes:
  15.  
  16. >A non-recursive method:  (assuming a 16 bit integer)
  17. >
  18. >    for(count=32768;count>0;count/=2){
  19. >      printf("%d",(num & count ? 1 : 0));
  20. >    }
  21.  
  22. Be careful what type you make count. If it is a 16 bit int then it can't
  23. hold the number 32768 and the code has implementation-defined behaviour.
  24.  
  25. -- 
  26. -----------------------------------------
  27. Lawrence Kirby | fred@genesis.demon.co.uk
  28. Wilts, England | 70734.126@compuserve.com
  29. -----------------------------------------
  30.